<%@ page contentType="text/html; charset=UTF-8" language="java"%>
<%@ page import="com.hzqy.commons.utils.ConstantUtils" %>
<%@ page import="com.hzqy.web.vo.PmsUserVo"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta charset="UTF-8">
<title>天气修改</title>
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/defalut.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/public.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/ddspstyle.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/default/easyui.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/themes/icon.css">
<link rel="stylesheet" type="text/css"	href="../../static/js/WdatePicker/skin/WdatePicker.css">
<script type="text/javascript" src="../../static/js/jquery.min.js"></script>
<script type="text/javascript" src="../../static/js/jquery.easyui.min.js"></script>
<script type="text/javascript"	src="../../static/js/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript" src="../../static/js/jquery.validate.js"></script>
<script type="text/javascript" src="../../static/js/index.js"></script>
<script type="text/javascript" src="../../static/js/WdatePicker/WdatePicker.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/ueditor.all.min.js"></script>
<script type="text/javascript" charset="utf-8" src="../../ueditor/lang/zh-cn/zh-cn.js"></script>
	<script type="text/javascript" charset="utf-8" src="../../static/js/Base64.js"></script>
	<script type="text/javascript" charset="utf-8" src="../../static/js/beforeData.js"></script>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<%
String f_wf_id =request.getParameter("f_wf_id");
String []nonceObj=ConstantUtils.getNonceObject();
%>
<script type="text/javascript">
	
	$(function() {
		$.ajax({
			url:"../../statistics/area_tree.do?f_sa_id=0",
			success:function(data) {
				data = JSON.parse(data);
				var str = "";
				for(var i=0;i<data.length;i++) {
					str+='<option value="'+data[i].id+'">'+data[i].name+'</option>';
				}
				$("#f_wf_userarea").append(str);
			}
		});
		var f_wf_id = <%=f_wf_id%>;
		$.ajax({
			url:"../../weather_forecast/select_weather.do?f_wf_id="+f_wf_id,
			success:function(data) {
				data = JSON.parse(data);
				$("#f_wf_id").val(data.f_wf_id);
				$("#f_wf_userarea").val(data.f_wf_userarea);
				$("#f_wf_minTemperature").val(data.f_wf_minTemperature);
				$("#f_wf_maxTemperature").val(data.f_wf_maxTemperature);
				$("#f_wf_weather").val(data.f_wf_weather);
				$("#f_wf_date").val(data.f_wf_date);
				beforeData(data, f_wf_id, "", "../../beforeData.do");
				/* var areaArr = (data.f_wf_cityid).split("-");
				$("#prov").val(areaArr[0]);
				$("#city").val(areaArr[1]);
				showCountry(city);
				$("#country").val(areaArr[2]);  */
			}
	    }); 
		$("#contentForm").validate({
			rules: {
				f_wf_userarea: {
					required: true
				},
				f_wf_minTemperature:{
					required:true
				},
				f_wf_maxTemperature:{
					required:true
				},
				f_wf_weather:{
					required:true
				},
				f_wf_date:{
					required:true
				}
				
			},
			messages: {
				f_wf_userarea: {
					required: "请选择地区"
				},
				f_wf_minTemperature:{
					required:"请填写最低气温"
				},
				f_wf_maxTemperature:{
					required:"请填写最高气温"
				},
				f_wf_weather:{
					required:"请填写天气状况"
				},
				f_wf_date:{
					required:"请填写天气当天时间"
				}
			}
			
		});
	});

	function _submitFm() {
		if($("#f_wf_userarea").val()== '0'){
			$.messager.alert('提示', '请选择地区！', 'info', function() {
				$.messager.progress('close');
			});
			return ;
		}
		var f_wf_city=$("#f_wf_userarea").find("option:selected").text();
		$("#f_wf_city").val(f_wf_city);
		
		/* var f_wf_cityid = getAddress();
		var f_wf_city="";
		var areaArr = f_wf_cityid.split("-");
		for(var  i=0;i<areaArr.length;i++){
			if(areaArr[i] == ''){
				$.messager.alert('提示', '请选择城市！', 'info', function() {
					$.messager.progress('close');
				});
				return ;
			}
		}
		$("#f_wf_cityid").val(f_wf_cityid);
		if(f_wf_cityid == ""){
			f_wf_city = "";
		}else{
			f_wf_city = provice[areaArr[0]].city[areaArr[1]].districtAndCounty[areaArr[2]];
		}
		$("#f_wf_city").val(f_wf_city);
		 */
		if($("#contentForm").validate().form()) {
			app_ajax('../../weather_forecast/update_weather.do', $("#contentForm").serialize(), function(data) {
					if (data.success) {
						$.messager.progress('close');
						$.messager.alert('提示', '提交成功！', 'info', function() {
							parent.$('#dlg').dialog('close');
							parent.gotoSearch($('#easyui-treegrid'));
						});
					} else {
						$.messager.alert('提示', data.result, 'info', function() {
							$.messager.progress('close');
						});
					}
			});
	  }
	}
	
	function getAddress(){
		var prov = $("#prov").val();
		var city = $("#city").val();
		var country = $("#country").val();
		var str="";
		str = prov+"-"+city+"-"+country;
		return str;
	}
</script>
<style type="text/css">
</style>
</head>

<body class="overfwidth">
	<div class="barnavtop">您所在的位置：天气预报管理 &gt; 天气修改</div>
	<div id="workspace">
		<!--主体 开始-->
		<div id="container-1">
			<div class="editspace">
				<form id="contentForm" class="cmxform" enctype="multipart/form-data" name="formName">
					<input name="f_wf_id" id="f_wf_id" type="hidden" onkeydown="onpress();" />
					<input name="f_wf_city" id="f_wf_city" type="hidden" onkeydown="onpress();" />
					<legend style="text-align: center; margin: 0 auto;">天气修改</legend>
					<fieldset >
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" align="right">
										<span class="red">*</span>地区：
									</td>
									<td width="30%">
										<select id="f_wf_userarea" name="f_wf_userarea" style="width: 150px;">
												<option value="0">--请选择--</option>
										</select>
										<span id="f_wf_userarea_tip" class="tip"></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					<!-- <fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" align="right">
										<span class="red">*</span>城市：
									</td>
									<td width="30%">
										<select id="prov" onfocus="this.defaultIndex=this.selectedIndedx;" onchange="this.selectedIndex=this.defaultIndex;" style="width: 80px;">
								                <option value="11">浙江省</option>
										</select>
										<select id="city" name="city" onchange="showCountry(this)" style="width: 80px;">
															<option value="">请选择</option>
										</select> 
										<select id="country" style="width: 80px;">
															<option value="">请选择</option>
										</select>
										<input name="f_wf_city" id="f_wf_city" type="hidden" onkeydown="onpress();" />
										<input name="f_wf_cityid" id="f_wf_cityid" type="hidden" onkeydown="onpress();" />
									</td>
								</tr>
							</table>
						</div>
					</fieldset> -->
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" align="right">
										<span class="red">*</span>时间：
									</td>
									<td width="30%">
										<input id="f_wf_date" name="f_wf_date" type="text" onClick="WdatePicker({skin:'default',dateFmt: 'yyyy-MM-dd HH:mm:ss'})"  onkeydown="onpress();" style="width: 150px;"  value="" class="yl_inp yw_name" />	
										<span id="f_wf_date_tip" class="tip"></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" align="right">
										<span class="red">*</span>最低气温/℃：
									</td>
									<td width="30%">
										<input id="f_wf_minTemperature" name="f_wf_minTemperature" style="width: 150px;" value="" class="yl_inp yw_name" />
										<span id="f_wf_minTemperature_tip" class="tip"></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
									<td width="20%" align="right">
										<span class="red">*</span>最高气温/℃：
									</td>
									<td width="30%">
										<input id="f_wf_maxTemperature" name="f_wf_maxTemperature" style="width: 150px;" value="" class="yl_inp yw_name" />
										<span id="f_wf_maxTemperature_tip" class="tip"></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					
					<fieldset>
						<div class="fitem">
							<table width="100%" border="0" cellpadding="0" cellspacing="0">
								<tr>
								    <td width="20%" align="right">
										<span class="red">*</span>天气状况：
									</td>
									<td width="30%">
										<textarea id="f_wf_weather" name="f_wf_weather" rows="3" cols="40" ></textarea>
										<span id="f_wf_weather_tip" class="tip"></span>
									</td>
								</tr>
							</table>
						</div>
					</fieldset>
					<input type="hidden" name="stime" value="<%=nonceObj[0]%>"/>
					<input type="hidden" name="sign" value="<%=nonceObj[1]%>"/>
					
					<div class="toolbar" style="text-align: center;">
						<a class="easyui-linkbutton" data-options="iconCls:'icon-ok'"
							href="javascript:void(0);" onclick="_submitFm()">保存</a> <a
							href="javascript:void(0);" data-options="iconCls:'icon-cancel'"
							class="easyui-linkbutton"
							onclick="javascript:parent.$('#dlg').dialog('close')">取消</a>
					</div>
				</form>
			</div>
		</div>
		<!--主体 结束-->
	</div>
	<div id="org_list" class="easyui-dialog"
		style="width: 600px; height: 500px; padding-top: 0px;"
		data-options="title:'客户选择', iconCls:'icon-save',modal:true,closed:true,buttons:'#dlg_buttons'">
		<iframe scrolling="auto" frameborder="0"
			style="width: 100%; height: 99%;"></iframe>
	</div>
</body>
<!-- <script type="text/javascript" src="../../static/js/city/city.js"></script>
<script type="text/javascript" src="../../static/js/city/method01.js"></script> -->
</html>
